package com.hk.mybatis.config;

/**
 * @author miaoj
 */
public class ProjectContextHolder {
    private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();

    public static final String DEFAULT_CODE = null;

    public static String getCurrentProjectCode() {
        String dataSource = CONTEXT_HOLDER.get();
        if (dataSource != null) {
            return dataSource;
        }
        return DEFAULT_CODE;
    }

    public static void setCurrentProjectCode(String key) {
        CONTEXT_HOLDER.set(key);
    }

    public static void clear() {
        CONTEXT_HOLDER.remove();
    }
}
